const mongoose = require('mongoose');
const DB_URL = 'mongodb://localhost:27017/oilapp';

//连接数据库
mongoose.connect(DB_URL);

//连接成功
mongoose.connection.on('connected', function(){
  console.log('mongodb数据库连接成功')
})

//连接异常
mongoose.connection.on('error', function(err){
  console.log(`数据库连接出错：${err}`)
})

//连接断开
mongoose.connection.on('disconnected', function(){
  console.log('数据库断开连接')
})